#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

const int M = 1e6 + 6;

typedef long long ll;

int n, m, L, V;

int d[N], v[N], a[N], p[N];

int sum[M];

vector<pair<int, int>> seg;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int tt;
    cin >> tt;
    while (tt--) {
        seg.clear();
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) {
            cin >> d[i] >> v[i] >> a[i];
        }
        for (int i = 1; i <= m; i++) {
            cin >> p[i];
        }
        sort(p + 1, p + 1 + m);
        p[m + 1] = -1;
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] == 0) {
                if (v[i] > V) {
                    //sum[d[i]] += 1;
                    //sum[L + 1] -= 1;
                    int found = lower_bound(p + 1, p + 1 + m, d[i]) - p;
                    if (p[found] == -1) continue;
                    if (p[found] <= L) {
                        seg.push_back({d[i], L});
                    }
                }
            }
            if (a[i] > 0) {
                ll k = (1ll * V * V - 1ll * v[i] * v[i]) / (2ll * a[i]);
                if (k + d[i] + 1 <= L) {
                    //sum[k + d[i]] += 1;
                    //sum[L + 1] -= 1;
                    int found = lower_bound(p + 1, p + 1 + m, d[i] + k + 1) - p;
                    if (p[found] == -1) continue;
                    if (p[found] <= L) {
                        seg.push_back({k + d[i] + 1, L});
                    }
                }
            }
            if (a[i] < 0) {
                if (v[i] <= V) continue;
                ll k;
                if ((1ll * V * V - 1ll * v[i] * v[i]) % (2ll * a[i]) == 0) {
                    k = (1ll * V * V - 1ll * v[i] * v[i]) / (2ll * a[i]) - 1;
                } else {
                    k = (1ll * V * V - 1ll * v[i] * v[i]) / (2ll * a[i]);
                }
                //sum[d[i]] += 1;
                int r = min(1ll * L, d[i] + k);
                //sum[r + 1] -= 1;
                int found = lower_bound(p + 1, p + 1 + m, d[i]) - p;
                if (p[found] == -1) continue;
                if (d[i] <= r) {
                    if (p[found] <= r) {
                        seg.push_back({d[i], r});
                    }
                }
            }
        }
        sort(seg.begin(), seg.end());
        cout << seg.size() << ' ';
        seg.push_back({1e9, 1e9});
        int cnt = seg.size();
        int mnr = 1e9;
        int res = 0;
        for (int i = 0; i < cnt; i++) {
            int found = lower_bound(p + 1, p + 1 + m, seg[i].first) - p;
            mnr = min(mnr, seg[i].second);
            //cout << mnr << ' ' << p[found] << '\n';
            if (seg[i].first > mnr || p[found] > mnr) {
                res += 1;
                mnr = seg[i].second;
            }
        }
        cout << m - res << '\n';
    }
    return 0;
}
